﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

using QuDao;
using FineUICore;
using Kalman;
using Kalman.Extensions;

namespace AdminUI.Pages.SysManage
{
    public partial class SysUserAddModel : BaseModel
    {
        public void OnGet()
        {
            var roleList = RoleBO.Instance.GetList<Role>();

            roleList.Add(new Role { RoleID = -1, RoleName = "超级管理员" });
            ViewBag.RoleList = roleList;
        }

        public IActionResult OnPostBtnSubmit_Click(SysUser dto, string pwd)
        {
            var id = SysUserBO.Instance.Add(pwd, dto);
            LogAction(ActionType.新增, $"新增用户：{id}-{dto.UserName}");

            FineUICore.PageContext.RegisterStartupScript(ActiveWindow.GetHideRefreshReference());
            //ActiveWindow.HidePostBack();
            return UIHelper.Result();
        }

    }
}